package com.example.springaop_2.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Date:2022-11-03
 * Time:17:59
 *
 * @Author: 东莞呵呵
 */
@ControllerAdvice
public class ExceptionAdvice {
    @ExceptionHandler(Exception.class)
    public HashMap<String,Object> exception(Exception e){
        HashMap<String,Object> result =new HashMap<>();
        result.put("state",-1);
        result.put("data",null);
        result.put("msg","异常："+e.getMessage());
        return result;
    }
}
